<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>首页</title>
    <script type="text/javascript" th:src="@{/bootstrap-4.5.0-dist/js/jquery-3.2.1.slim.min.js}"></script>
    <script type="text/javascript" th:src="@{/bootstrap-4.5.0-dist/js/bootstrap.js}"></script>
    <link type="text/css" rel="stylesheet" th:href="@{/bootstrap-4.5.0-dist/css/bootstrap.css}">

    <style type="text/css">
        .download{
            width: 800px;
            height: 250px;
            overflow-x: hidden;
            overflow-y: scroll;
        }
        .download::-webkit-scrollbar{
            display: none;
        }
    </style>
</head>
<body>

<div class="container">
    <ul class="nav justify-content-end">
        <li class="nav-item">
            <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">
                你好,[[${session.userlogin}]]<span th:text="${session.userrole}==2?'【老师用户】':'【学生用户】'"></span>
            </a>
        </li>
        <li class="nav-item">
        <a class="nav-link" href="/loginOut">退出</a>
        </li>
    </ul>

    <div id="upload" th:hidden="${session.userrole}==1?true:false" class="row">

        <form method="post" enctype="multipart/form-data" th:action="@{/upload}">
            <input type="file" name="file">
            <button class="btn btn-outline-secondary" type="submit">上传</button>
        </form>
    </div>

    <div class="download row" >
        <table class="table table-hover" th:width="800px" style="margin: 0 auto">
            <thead>
            <tr>
                <th>文件名</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="f : ${fileList}">
                <td th:text="${f.getFilename()}"></td>
                <td>
                    <a class="btn btn-sm btn-primary" th:href="@{/download/{filename}(filename=${f.getFilename()})}">下载</a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>

</div>




</body>
<script  language="javascript" type="text/javascript"  th:inline="javascript">
    onload=function(){
        var filemsg =  [[${filemsg}]];
        if(filemsg){
            alert(filemsg);
        }
    };
</script>
</html>